package com.ophiux.cs.application.appraise.remote;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.cs.application.core.Result;
import com.ophiux.cs.application.user.dto.getUserByUseridRequest;
import com.ophiux.cs.application.user.dto.getUserByUseridResponse;
import com.ophiux.cs.application.user.service.IUserAppService;
import com.ophiux.cs.domain.appraise.remote.IAppraise_UserRemoteService;
import com.ophiux.utils.exception.OphiuxRemoteException;
import com.ophiux.utils.parser.json.JsonUtils;

import lombok.extern.slf4j.Slf4j;

/**
 * 说明：调用用户层远程api<br>
 * <h1>创 建 人: hehailong<br></h1>
 * 创建日期: 2018年9月10日 上午11:42:06<br>
 * 修改记录：
 */
@Service
@Slf4j
public class Appraise_UserRemoteService implements IAppraise_UserRemoteService{
	@Autowired
	IUserAppService userAppService;
	
	@Override
	public boolean getUserIsExist(String userID) throws OphiuxRemoteException {
		try {
			getUserByUseridRequest dto = new getUserByUseridRequest();
			dto.setUSER_ID(userID);
			Result<getUserByUseridResponse> result = userAppService.getUserByUserid(dto);
			if(!result.isSuccess()) {
				log.info("调用远程API,Appraise_UserRemoteService=>getUserIsExist失败,返回参数",JsonUtils.toJson(result));
				throw new OphiuxRemoteException("调用远程API,Appraise_UserRemoteService=>getUserIsExist失败");
			}
			getUserByUseridResponse resp = result.getRESPONSE();
			if(resp!=null) {
				return true;
			}
			return false;
		} catch (Exception e) {
			e.printStackTrace();
			log.info("调用远程API,Appraise_UserRemoteService=>getUserIsExist异常",e);
			throw new OphiuxRemoteException(e);
		}
	}

}
